package com.oocl.im.util;

import static org.junit.Assert.*;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.junit.Test;

import com.oocl.im.pojo.MsgPackage;
import com.oocl.im.pojo.Operation;

public class JsonUtilTest {

	@Test
	public void testObjectToString() {
		Map<String, Boolean> map = new HashMap<String,Boolean>();
		map.put("wyatt", true);
		map.put("marvin", false);
		MsgPackage msg = new MsgPackage(Operation.CHAT, "sender", "receive", "qqq",
				new Date(),(HashMap<String, Boolean>) map);
		System.out.println(msg.getContent());
		String s = JsonUtil.objectToString(msg);
		System.out.println(s);
	}

	@Test
	public void testStringToObject() {
		Map<String, Boolean> map = new HashMap<String,Boolean>();
		map.put("wyatt", true);
		map.put("marvin", false);
		MsgPackage msg = new MsgPackage(Operation.EXIT, "sender1", "receive1", "111",
				new Date(),(HashMap<String, Boolean>) map);
		String s = JsonUtil.objectToString(msg);
		MsgPackage msg1 = JsonUtil.stringToObject(s);
		System.out.println(msg1.toString());
		System.out.println(msg1.getDate());
	}

}
